import { readFile } from "fs/promises";
const pkg = JSON.parse(
  await readFile(new URL("../../package.json", import.meta.url))
);
export function initConfigFile(_answers, config) {
  const configContent = `module.exports = ${JSON.stringify(config, null, 2)};`;
  try {
    fs.writeFileSync(`./${pkg.name}.config.js`, configContent);
  } catch (err) {
    if (err.code === "EEXIST") {
      console.error("项目文件夹已存在，无法创建");
      throw err;
    }
  }
}
